home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / misc / GMSV03B.lha / GamesMaster / Source / E / ScreenDemos / DoubleBuffer.e < prev    next >
Encoding:
Text File  |  1996-09-11  |  2.3 KB  |  68 lines

  1. /* Double Buffering
  2. ** ----------------
  3. ** This just shows how to double buffer the screen.  You can also try out
  4. ** triple buffering just by changing the DBLBUFFER flag to TPLBUFFER in the
  5. ** ScreenStruct.
  6. ** 
  7. ** Notice that this thing does in fact fully multi-task (no forbid/permit)!
  8. ** Instead we set our task priority to be a little higher than any other
  9. ** tasks -- if we didn't do this sometimes our frames could be stalled (try
  10. ** removing the SetUserPri and watch the demo again).
  11. */
  12.  
  13. MODULE 'games','games/games'
  14.  
  15. PROC main()
  16.    DEF screen:PTR TO gamescreen, palette:PTR TO INT, loadpic:PTR TO picture
  17.  
  18.    palette := [    $0000,$0130,$0FCB,$0FA9,$0D88,$0965,$0644,$0211,
  19.         $0400,$0444,$0FF0,$0432,$0CC0,$0150,$0501,$0880,
  20.         $0261,$0271,$0382,$0492,$05A3,$05B4,$0677,$06C4,
  21.         $0788,$09AA,$0BCC,$0801,$0901,$0A02,$0701,$0601
  22.           ]:INT;
  23.  
  24.    screen :=  [    GSV1,0,
  25.         0,0,0,            -> Screen_Mem1/2/3
  26.         0,                -> Screen link.
  27.         palette,          -> Address of palette.
  28.         0,                -> Address of rasterlist.
  29.         0,                -> Amt of colours in palette.
  30.         320,256,320,256,  -> Screen & Pic Height/Width.
  31.         5,                -> Amt of planes.
  32.         0,0,              -> Top of screen offsets, X/Y
  33.         0,0,              -> X/Y counters (for scrolling).
  34.         DBLBUFFER,        -> Special attributes.
  35.         LORES,            -> Screen mode.
  36.         INTERLEAVED,      -> Screen type
  37.         0                 -> Reserved area.               
  38.           ]:gamescreen;    
  39.  
  40.    loadpic := [    PCV1,0,             -> Version header.
  41.         0,                  -> Destination.
  42.         320,256,            -> Width, Height.
  43.         5,                  -> Amount of Planes.
  44.         32,                 -> Amount of colours.
  45.         palette,            -> Palette (remap).
  46.         LORES,              -> Screen mode.
  47.         INTERLEAVED,        -> Destination.
  48.         0                   -> Parameters.
  49.               ]:picture;
  50.  
  51.    IF gmsbase := OpenLibrary('games.library',0)
  52.       SetUserPri()
  53.       IF (Add_Screen(screen) = ERR_OK)
  54.          loadpic.data := screen.memptr1;
  55.          IF (LoadPic('GAMESLIB:data/IFF.Pic320',loadpic) = ERR_OK)
  56.             Show_Screen(screen)
  57.         REPEAT
  58.           Wait_OSVBL()
  59.           SwapBuffers(screen)
  60.         UNTIL !(Read_Mouse(JPORT1) AND MB_LMB)
  61.          ENDIF
  62.     Delete_Screen(screen)        
  63.       ENDIF
  64.    CloseLibrary(gmsbase)
  65.    ENDIF
  66. ENDPROC
  67.  
  68.